FLAGS=-Iinclude -I../threadpool/include
FLAGS+=-I../utils/include -fPIC -Wall -O2
LDFLAGS=-lpthread -ldl -lrt

debugsuf=_d
libname=liblogger
libsuf=.so

sources=$(wildcard src/*.cpp)
#sources+=$(wildcard ../utils/src/*.cpp)
objects = $(patsubst %.cpp,%.o,$(sources))
objects_d = $(patsubst %.cpp,%$(debugsuf).o,$(sources))

all:debug release
debug:$(libname)$(debugsuf)$(libsuf)
release:$(libname)$(libsuf)

# debug
$(libname)$(debugsuf)$(libsuf):$(objects_d)
	g++ -shared $^ -o $@ $(LDFLAGS)

$(objects_d):%$(debugsuf).o:%.cpp
	@echo "************ Compiling" $<
	g++ -g -c $< $(FLAGS) -o $@

#release
$(libname)$(libsuf):$(objects)
	g++ -shared $^ -o $@ $(LDFLAGS)

$(objects):%.o:%.cpp
	@echo "************ Compiling" $<
	g++ -c $< $(FLAGS) -o $@

clean:
	-rm -f $(objects) $(objects_d) $(libname)$(debugsuf)$(libsuf) $(libname)$(libsuf)
	$(MAKE) -C example clean

